var api = require('../../utils/api.js')

Page({
    data: {
        list: [],
        user:''
    },
    onLoad() {

    },
    onShow() {
        var that=this;
        api.post({
            url: 'user/index' ,
            data: {},
            success: data => {
                console.log(data);
                that.setData({
                    user:data.data
                })
            }
        })

        this.getmydata();

    },

    // 获取数据
    getmydata(){
        var that=this;
        api.post({
            url: 'merchlist/getmerchlistinfo' ,
            data: {},
            success: data => {
                console.log(data);
                that.setData({
                    infos:data.data
                })
            }
        })
    },



    loginout(){
        wx.reLaunch({
          url: '/pages/login/login',
        })

    },
    seemylogs(){
        wx.navigateTo({
          url: '/pages/comment/comment',
        })
    },
    seemydata(ret){

        console.log(ret);
        var i=ret.currentTarget.dataset.i;

        wx.navigateTo({
            url: '/pages/favorite/index?i='+i
          })
    },
    seemydataview(){
        wx.navigateTo({
            url: '/pages/data/index',
          })
    },
    // 解除绑定
    clearmobile(){
        var that=this;
        wx.showModal({
          title: '温馨提示',
          content: '确认要解绑信息？',
          complete: (res) => {
            if (res.confirm) {
                api.post({
                    url: 'user/clearmobile' ,
                    data: {},
                    success: data => {
                        console.log(data);
                        wx.setStorageSync('token', '');
                        wx.setStorageSync('userinfo', '');
                        wx.navigateTo({
                          url: '/pages/login/login',
                        })
                    }
                })
            }
          }
        })

    }


});